package com.cch.android.activity.view.ad;

import android.app.Activity;

import com.google.ads.Ad;
import com.google.ads.AdListener;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import com.google.ads.AdRequest.ErrorCode;

public class MyAdView extends AdView {

	public MyAdView(Activity activity, AdSize adSize, String adUnitId) {
		super(activity, adSize, adUnitId);
	}

	public MyAdView(Activity activity) {
		
		this(activity, AdSize.BANNER, "a14efa6ffa93322");
		System.out.println("admob广告");
		setAdListener(adListener);
	}
	/**
	 * 监听器
	 */
	private AdListener adListener = new AdListener() {

		@Override
		public void onDismissScreen(Ad arg0) {
			 System.out.println(">>>>>onDismissScreen:");
		}

		//请求失败
		@Override
		public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
			 System.out.println(">>>>>onFailedToReceiveAd:");

		}

		@Override
		public void onLeaveApplication(Ad arg0) {
			 System.out.println(">>>>>onLeaveApplication:");
		}
		//广告被点击时
		@Override
		public void onPresentScreen(Ad arg0) {
			 System.out.println(">>>>>onPresentScreen:");
		}

		//接收请求
		@Override
		public void onReceiveAd(Ad arg0) {
			 System.out.println(">>>>>onReceiveAd:");
		}

	};
}
